package model

import (
	"gorm.io/gorm"
	__ "user-srv/basic/proto"
)

type Video struct {
	gorm.Model
	UserId int     `gorm:"type:int(11)" json:"userId"`
	Title  string  `gorm:"type:varchar(30)" json:"title"`
	Image  string  `gorm:"type:varchar(255)" json:"image"`
	Info   string  `gorm:"type:varchar(50)" json:"info"`
	Price  float32 `gorm:"type:decimal(10,2)" json:"price"`
	Num    int     `gorm:"type:int(11)" json:"num"`
	Types  int     `gorm:"type:int(11)" json:"types"`
	Status int     `gorm:"type:int(11)" json:"status"`
}

func (v *Video) GetOnfile(db *gorm.DB, title string) error {
	return db.Model(&v).Where("title = ?", title).Limit(1).Find(&v).Error
}
func (v *Video) Create(db *gorm.DB) error {
	return db.Model(&v).Create(&v).Error
}
func (v *Video) Update(db *gorm.DB, Id int) error {
	return db.Model(&v).Where("id = ?", Id).Updates(&v).Error
}
func (v *Video) Getcover(db *gorm.DB) (list []*__.VideoList, err error) {
	err = db.Model(&v).Find(&list).Error
	return
}
